package sk.fiit.icp.data;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public class EventCategoriesDaoImpl implements EventCategoriesDao {

	private HibernateTemplate hibernateTemplate;

	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		hibernateTemplate = new HibernateTemplate(sessionFactory);
	}

	@Transactional(readOnly = false)
	public void persist(EventCategories ec) {
		hibernateTemplate.persist("EventCategories", ec);
	}

	@SuppressWarnings("unchecked")
	public List<EventCategories> findAll() {
		return hibernateTemplate.find("from EventCategories");
	}

}
